package org.acompanhamento.pages.team;

import java.util.List;

import jmine.tec.di.annotation.Injected;
import jmine.tec.report.impl.table.ReportTableBuilder;
import jmine.tec.web.wicket.pages.form.CrudModelPage;
import jmine.tec.web.wicket.pages.form.FormType;

import org.acompanhamento.HelpMessages;
import org.acompanhamento.domain.Team;
import org.apache.wicket.Page;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import bancosys.tec.exception.MessageCreator;
import bancosys.tec.persist.dao.BaseDAO;
import bancosys.tec.persist.dao.BaseDAOFactory;
import bancosys.tec.security.annotation.Secure;
import bancosys.tec.security.authorization.UrlPermission;

@Secure(id = "GENERIC_TEAM_MEMBER_URL", permissionType = UrlPermission.class)
public class ListTeamPage extends CrudModelPage<TeamFilterVO, Team> {

	@Injected
	private BaseDAO<Team> teamDAO;

	@Override
	public Page createNewPage() {
		return new EditTeamPage(new PageParameters(), this);
	}

	@Override
	public List<Team> search(BaseDAOFactory daoFactory) {
		return this.teamDAO.findByLikeNaturalKey(this.getModel().getName());
	}

	@Override
	protected Page createFormPage(Team entity, FormType formType) {
		return new EditTeamPage(this, new PageParameters(), entity, formType);
	}

	@Override
	protected void addResultTableColumns(ReportTableBuilder<Team> table) {
		table.addStringColumn("name", "Name", "name");
	}

	@Override
	protected TeamFilterVO createModel() {
		return new TeamFilterVO();
	}

	@Override
	protected MessageCreator getHelpTextCreator() {
		return HelpMessages.TEAMS;
	}

}
